//
//  ST_EditMyGardenCell.swift
//  btvideo
//
//  Created by Jason on 2021/7/21.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit

class ST_EditMyGardenCell: UITableViewCell {
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        contentView.addSubview(cover_image_view)
        cover_image_view.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.centerY.equalToSuperview()
            make.height.equalTo(92)
            make.width.equalTo(60)
        }
        
        
        contentView.addSubview(edit_image_icon_view)
        edit_image_icon_view.snp.makeConstraints { make in
            make.width.height.equalTo(20)
            make.right.bottom.equalTo(cover_image_view)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var cover_image_view:UIImageView = {
        let v = UIImageView()
        v.contentMode = .scaleAspectFill
        v.clipsToBounds = true
        v.cornerRadius = 5
        return v
    }()
    
    fileprivate lazy var edit_image_icon_view:UIImageView = {
        let v = UIImageView(image: ST_ImageUtils.imageName("room_cover_edit"))
        return v
    }()
    
    
    func bind(model:ST_EditMyGardenCellModel) {
        
//        model.imageUrl.path
        
        if let img = model.img{
            cover_image_view.image = img
        }else{
            cover_image_view.pin_setImage(from: model.imageUrl, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
        }
        
    }
    
}
